package com.runoob.java;


/**
 * 多态
 *
 */
public class Multiple {
    public static void main(String[] args) {
        Salary s = new Salary("员工 A", "北京", 123, 9980.00);
        Employee2 e = new Salary("员工 B", "上海", 456, 7780.00);
        s.mailCheck();
        e.mailCheck();
    }
}



class Employee2 {
    private String name;
    private String address;
    private int number;

    public Employee2(String name, String address, int number) {
        System.out.println("Employee2 构造函数！");
        this.name = name;
        this.address = address;
        this.number = number;
    }

    public void mailCheck() {
        System.out.println("邮寄支票给：" + this.name + "  " + this.address);
    }

    public String toString() {
        return name + " " + address + "  " + number;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }
}

class Salary extends Employee2{
    private double salary; // 全年工资
    public Salary (String name, String address, int number, double salary) {
        super(name, address, number);
        this.salary = salary;
    }

    public void mailCheck() {
        System.out.println("Salary类的mailCheck方法 ");
        System.out.println("邮寄支票给：" + this.getName() + "  " + this.getAddress() + " 工资为: " + this.salary);
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double newSalary) {
        if (salary > 0.0) {
            salary = newSalary;
        }
    }

    public double computePay() {
        System.out.println("计算工资， 付给 : " + getName());
        return  salary / 52;
    }
}